package com.atguigu.gulimall.cart.entity;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author dengchujun
 * @Description
 * @date 2024/6/7
 */
public class CartVo {

    /**
     * 购物车子项信息
     **/
   private List<CartItemVo> items;

    /**
     * 商品的总数量
     */
   private Integer countNum;

    /**
     * 商品的类型数量
     */
   private Integer countType;

    /**
     * 商品总价
     */
   private BigDecimal totalAmount;

    /**
     * 减免价格
     */
   private BigDecimal reduce=new BigDecimal("0");

    public List<CartItemVo> getItems() {
        return items;
    }

    public void setItems(List<CartItemVo> items) {
        this.items = items;
    }

    public Integer getCountNum() {
        int count =0;
        if (items!=null && items.size()>0){
            for (CartItemVo item : items) {
                count += item.getCount();
            }
        }
        return count;
    }

    public void setCountNum(Integer countNum) {
        this.countNum = countNum;
    }

    public Integer getCountType() {
        int count =0;
        if (items!=null && items.size()>0){
            count=items.size();
        }
        return count;
    }

    public void setCountType(Integer countType) {
        this.countType = countType;
    }

    public BigDecimal getTotalAmount() {
        BigDecimal amount=new BigDecimal("0");
        if (items!=null && items.size()>0){
            for (CartItemVo item : items) {
                if (item.getCheck()){
                    amount =amount.add(item.getTotalPrice());
                }
            }
        }
        BigDecimal subtract=amount.subtract(reduce);
        return subtract;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
